// 售货机
import request from '@/utils/request'
// 搜索售货机(售货机列表)
export const vmSearchList = (params) => {
  return request({
    url: `/api/vm-service/vm/search`, // 设备编号
    params
  })
}
// 售货机类型列表(搜索)
export const vmTypeSearch = (params) => {
  return request({
    url: `/api/vm-service/vmType/search`, // 设备编号
    params
  })
}
// api/vm-service/vm新增售货机
export const addVm = (data) => {
  return request({
    url: `/api/vm-service/vm`, // 设备编号
    data,
    method: 'POST'
  })
}
// /api/vm-service/vm/:id/:nodeId 修改售货机
/**
 *
 * @param {id} 售货机Id
 * @param {nodeId} 点位Id
 * @returns {boolean}
 */
export const editVm = (id, nodeId) => {
  return request({
    url: `/api/vm-service/vm/${id}/${nodeId}`, // 设备编号
    method: 'PUT'
  })
}
// 应用策略
export const applyPolicy = (data) => {
  return request({
    url: `/api/vm-service/vm/applyPolicy`, // 设备编号
    method: 'PUT',
    data
  })
}
// 策略列表
export const policyList = () => {
  return request({
    url: `/api/vm-service/policy`
  })
}
// 取消策略
/**
 *
 * @param {innerCode} 售货机编号
 * @param {policyId} 策略Id
 * @returns {boolean}
 */
export const cancelPolicy = (innerCode, policyId) => {
  return request({
    url: `/api/vm-service/vm/cancelPolicy/${innerCode}/${policyId}`, // 设备编号
    method: 'PUT'
  })
}
// 获取售货机货道详情
export const channelList = (innerCode) => {
  return request({
    url: `/api/vm-service/channel/channelList/${innerCode}`
  })
}
// 售货机类型详情
export const vmTypeApi = (typeId) => {
  return request({
    url: `/api/vm-service/vmType/${typeId}`
  })
}
// 货道配置
export const channelConfig = (data) => {
  return request({
    url: `/api/vm-service/channel/channelConfig`,
    method: 'PUT',
    data
  })
}
// 获取商圈下销量前10的商品(补货推荐)
export const businessTop = (businessId) => {
  return request({
    url: `/api/vm-service/sku/businessTop10/${businessId}`
  })
}
// 获取售货机维修次数
export const repairCount = (innerCode, start, end) => {
  return request({
    url: `/api/task-service/task/repairCount/${innerCode}/${start}/${end}`
  })
}
// 获取售货机补货次数
export const supplyCount = (innerCode, start, end) => {
  return request({
    url: `/api/task-service/task/supplyCount/${innerCode}/${start}/${end}`
  })
}
// 获取售货机商品销量
export const skuCollect = (innerCode, start, end) => {
  return request({
    url: `/api/order-service/report/skuCollect/${innerCode}/${start}/${end}`
  })
}
// 新增售货机类型
export const createVmType = (data) => {
  return request({
    url: `/api/vm-service/vmType`,
    method: 'POST',
    data
  })
}
// 售货机类型修改
export const editVmType = (typeId, data) => {
  return request({
    url: `/api/vm-service/vmType/${typeId}`,
    method: 'PUT',
    data
  })
}
// 售货机类型删除
export const delVmType = (typeId) => {
  return request({
    url: `/api/vm-service/vmType/${typeId}`,
    method: 'DELETE'
  })
}
